<template>
  <div class="input-option">
    <span class="name">{{ name }}</span>
    <input class="input" v-model="inputValue">
  </div>
</template>

<script>
export default {
  name: 'InputOption',
  props: {
    name: {
      type: String,
      default: ''
    },
    minValue: {
      type: Number,
      default: 0
    },
    value: null
  },
  data () {
    return {
      inputValue: this.value
    }
  },
  watch: {
    inputValue (newVal) {
      this.$emit(
        'update:value',
        this.minValue ? Math.max(this.minValue, this.inputValue) : newVal,
        this.name
      )
    }
  }
}
</script>

<style lang="scss">
.input-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 100%;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  .name {
    flex: 1 1 auto;
    text-align: center;
    padding: 15px 0;
    font-size: 13px;
    background: rgba(128, 128, 128, 0.3);
  }
  .input {
    flex: 0 1 auto;
    padding: 15px;
  }
}
</style>
